<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/plugins/vue/dist/vue.js"></script>
    <script src="js/plugins/axios/dist/axios.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
    <div id="wx">

    </div>
    <script type="text/javascript">
        new Vue({
            el: "#wx",
            mounted(){
                var url = location.href;
                var code = param2JsonObj(url).code
                this.$http.get("/login/wechat/" + code).then(res=>{
                    if (res.data.success){
                        alert("登陆成功！")
                        let {token, logininfo} = res.data.resultObj;
                        localStorage.setItem("token", token);
                        localStorage.setItem("logininfo", JSON.stringify(logininfo));
                        location.href = "/index.html"
                    }else {
                        var access_token = res.data.resultObj.access_token;
                        var openid = res.data.resultObj.openid;
                        location.href = "/binder.html?accessToken="+access_token+"&openId="+openid;
                    }

                }).catch(res=>{
                    alert("系统繁忙请稍后重试")
                })
            }
        })
    </script>

</body>

</html>